import axios from 'axios'

// action 类型
// 设置地址列表
export const SET_ADDRESS = 'SET_ADDRESS'
// 修改当前地址
export const CHANGE_ADDRESS = 'CHANGE_ADDRESS'
// 新增地址
export const ADD_ADDRESS = 'ADD_ADDRESS'


// 生成action

// 修改当前地址
export function changeAddress(address, id){
    return { type: CHANGE_ADDRESS, address, id }
}

// 新增地址
export function addAddress(options){
    return { type: ADD_ADDRESS, options }
}

export function getList(dispatch) {
    axios.get('/address').then(res => {
        dispatch({ type: SET_ADDRESS, address: res.data })
    })
}